package com.yz.design.strategyAndChain;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @Description: 处理者容器
 * @Auther: wuzhazha
 */
public class ReceiptHandlerContainer {

    private ReceiptHandlerContainer() {
    }


    public static List<IReceiptHandler> getReceiptHandlerList() {
        List<IReceiptHandler> receiptHandlerList = new ArrayList<>();
        //获取IReceiptHandler接口的实现类
        Set<Class<?>> classList = ReflectionUtil.getClassSetBySuper(IReceiptHandler.class);
        if (classList.size() > 0) {
            for (Class<?> clazz : classList) {
                try {
                    receiptHandlerList.add((IReceiptHandler) clazz.newInstance());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return receiptHandlerList;
    }

}